package com.zwf.mapper;

import com.github.pagehelper.Page;
import com.zwf.annotation.AutoFill;
import com.zwf.dto.CategoryDTO;
import com.zwf.dto.CategoryPageQueryDTO;
import com.zwf.entity.Category;
import com.zwf.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author zwf
 * @date 2024/1/31 20:57
 * @PackageName:com.zwf.mapper
 * @ClassName:CategoryMapper
 * @Description: TODO
 * @Version: 1.0
 */
@Mapper
public interface CategoryMapper {

    /**
     * 分类分页查询
     *
     * @param categoryPageQueryDTO
     * @return
     */
    Page<Category> pageQuery(CategoryPageQueryDTO categoryPageQueryDTO);

    /**
     * 修改分类
     * @param category
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Category category);

    /**
     * 新增分类
     * @param category
     */
    @Insert("insert into category (type, name, sort, status, create_time, update_time, create_user, update_user)" +
            "values" +
            "(#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(value = OperationType.INSERT)
    void add(Category category);

    /**
     * 根据id删除套餐
     * @param id
     */
    @Delete("delete from category where id = #{id}")
    void delete(Long id);

    /**
     * 根据类型查询分类
     * @param type
     * @return
     */
    List<Category> queryByType(Integer type);
}
